home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr51
/
brow1_01.zip
/
BROWDEMO.PRG
< prev
next >
Wrap
Text File
|
1993-04-01
|
7KB
|
229 lines
*:*********************************************************************
*:
*: Program: BROWDEMO.PRG
*:
*: System: BROWSE / POPUP Demo
*: Author: Ron Blechman
*: Copyright (c) 1990, Sound Processes, Inc.
*: Last modified: 08/16/90 5:03
*:
*: Procs & Fncts: KEYHAND
*: : KEYDISP
*:
*: Calls: KEYHAND (procedure in BROWDEMO.PRG)
*:
*: Uses: (DBFILE).DBF
*:
*: Binary Files: KEYBD.BIN
*:
*: Documented 08/16/90 at 05:06 SNAP! version 4.02d
*:*********************************************************************
**************************************************************************
* DISCLAIMER: This program is provided as is for demonstration
* purposes only. Its sole intent is for enlightenment
* within the dBASE development community.
* Feel free to incorporate these concepts within
* your own applications as you see fit.
* - Ron Blechman
***************************************************************************
SET TALK OFF
SET ESCAPE OFF
SET SCOREBOARD OFF
SET STATUS OFF
CLOSE ALL
db1_0 = ("1.0" $ VERSION()) && Set to True if dBASE IV 1.0
LOAD keybd
CLEAR
@ 20, 30 SAY "BROWDEMO - Version 1.01"
@ 6, 8 TO 18,72
@ 8, 16 SAY "The following is an demonstration of how BROWSE"
@ 9, 16 SAY "can be used as an alternative to POPUPs."
@ 11, 16 SAY "By: Ron Blechman"
@ 12, 20 SAY "Sound Processes, Inc."
@ 13, 20 SAY "6 Laurel Drive"
@ 14, 20 SAY "Fair Haven, NJ 07704"
@ 16, 16 SAY "Press any key to continue...."
foo = INKEY(0)
demoit = .T.
DO WHILE demoit
CLEAR
**************************************************************
* Browdemo.dbf has been indexed with 3 examples
* ORDER Fullname = UPPER(Lastname - "," - Firstname)
* ORDER Fullname2 = UPPER(Lastname - Firstname)
* ORDER Fullname3 = UPPER(Lastname + Firstname)
*
* Note that Fullname2 and Fullname3 have problems when
* searching/ording similar last and firstnames.
* (e.g. Try searching for the string "you")
**************************************************************
dbfile = "BROWDEMO"
dborder = "FULLNAME"
USE (dbfile)
SET ORDER TO (dborder)
@ 2, 4 SAY "Database File: "+dbfile
@ 3, 12 SAY "Order: "+dborder
matchstr = ""
uselect = .F.
SET EXACT OFF
CLEAR TYPEAHEAD
GOTO TOP
SET FIELDS TO
@ 21,10 SAY "Enter Search String, or Press ENTER to Select, or ESC to CANCEL."
@ 22,10 SAY "You may also use the cursor keys for positioning."
@ 18,24 SAY "Search String:"
DEFINE WINDOW browwin FROM 02,40 TO 15,65
DEFINE WINDOW inwin FROM 17,40 TO 19,65
ACTIVATE WINDOW inwin
matchstr = ""
uselect = .F.
ON KEY DO keyhand
BROWSE NOEDIT NOAPPEND NOMENU WINDOW browwin FIELDS ;
name = IIF(""=TRIM(firstname), lastname,TRIM(lastname)+", "+firstname)
ON KEY
RELEASE WINDOW browwin
RELEASE WINDOW inwin
CLEAR
@ 8,8 TO 12,78
IF uselect
@ 10,16 SAY "Name Selected:"
@ 10,31 SAY IIF(""=TRIM(firstname), lastname, TRIM(lastname)+", "+firstname)
ELSE
@ 10,30 SAY "Canceled Selection"
ENDIF
demoit = .F.
@ 14,20 SAY "Do you want to try it again? " GET demoit PICTURE "Y"
READ
ENDDO
RELEASE MODULE keybd
CLOSE ALL
CLEAR
RETURN
*!*********************************************************************
*!
*! Procedure: KEYHAND
*!
*! Called by: BROWDEMO.PRG
*! : KEYHAND (procedure in BROWDEMO.PRG)
*!
*! Calls: KEYHAND (procedure in BROWDEMO.PRG)
*! : KEYDISP (procedure in BROWDEMO.PRG)
*!
*! Binary Files: KEYBD.BIN
*!
*!*********************************************************************
PROCEDURE keyhand
ON KEY
trapkey = 26 && Set to numeric value of HOME, the "trap key"
userpress = INKEY(0)
DO CASE
CASE userpress = 27 && Esc will exit
** You MUST do two escapes for this to work
CALL keybd WITH CHR(27) + CHR(27)
uselect = .F.
GOTO TOP
CASE userpress = 13 && Enter will select
CALL keybd WITH CHR(27)
uselect = .T.
CASE userpress = trapkey && Home
*** Home is used as a special key - used with keyboard stuffing
CLEAR TYPEAHEAD
ON KEY DO keyhand
CASE userpress = 3 ;
.OR. userpress = 4 ;
.OR. userpress = 5 ;
.OR. userpress = 18 ;
.OR. userpress = 24 ;
.OR. userpress = 25 ;
.OR. userpress = 30 ;
.OR. userpress = 31
** Cursor movement keys
IF "" # matchstr
matchstr = ""
DO keydisp WITH ""
ENDIF
IF userpress = 25
** Ctrl-Y clears input string but preserves current record position
ON KEY DO keyhand
ELSE
** Stuff the keyboard buffer with cursor key to move record position
CALL keybd WITH CHR(userpress)+CHR(trapkey)
ON KEY LABEL home DO keyhand
ENDIF
OTHERWISE
** Search for input string
recnum = RECNO()
DO CASE
CASE userpress = 19 ;
.OR. userpress = 127
** Backspace or Left arrow erases one character
matchstr = SUBSTR(matchstr,1,LEN(matchstr)-1)
newstr = matchstr
OTHERWISE
newstr = matchstr + CHR(userpress)
ENDCASE
SEEK UPPER(newstr)
IF FOUND()
matchstr = newstr
DO keydisp WITH matchstr
************************************************************
* In dBASE IV 1.0, Browse will not automatically reposition
* screen UNLESS you move the cursor.
* In dBASE IV 1.1, you do not need to do this.
* **********************************************************
IF db1_0 .AND. recnum # RECNO()
CALL keybd WITH CHR(5) + CHR(trapkey) && UP/trapkey
ON KEY LABEL home DO keyhand
ELSE
ON KEY DO keyhand
ENDIF
ELSE
*** No Match
? CHR(7) && Beep
GOTO recnum
ON KEY DO keyhand
ENDIF
ENDCASE
RETURN
*!*********************************************************************
*!
*! Procedure: KEYDISP
*!
*! Called by: KEYHAND (procedure in BROWDEMO.PRG)
*!
*!*********************************************************************
PROCEDURE keydisp
PARAMETER dispstr
****************************************
* Display the current input string
****************************************
ACTIVATE WINDOW inwin
CLEAR
? dispstr
ACTIVATE WINDOW browwin
RETURN
*: EOF: BROWDEMO.PRG